package bishi.day46_7_7;

import java.util.*;

/**
 * @author 是阿秋啊
 * @date 2022/07/08 16:18
 **/
public class demo2 {
    static Scanner sc = new Scanner(System.in);
    static List<String> list = new LinkedList<>();
    static Map<String, Integer> map = new HashMap<>();

    public static void main(String[] args) {
        while (sc.hasNext()) {
            String str = sc.next();
            int row = sc.nextInt();

            StringBuffer sb = new StringBuffer();
            for (int i = str.length() - 1; i >= 0; i--) {
                if (str.charAt(i) == '\\') {
                    break;
                }
                if (str.length() - i - 1 == 16) {
                    break;
                }
                sb.append(str.charAt(i));
            }
            sb.reverse();
            sb.append(" ").append(row);
            String name = sb.toString();
            if (!list.contains(name)) {
                list.add(name);
            }
            map.put(name, map.getOrDefault(name, 0) + 1);
        }
        if (list.size() <= 8) {
            for (String s : list) {
                System.out.println(s +" "+ map.get(s));
            }
        } else {
            for (int i = list.size() - 8 - 1; i < list.size(); i++) {
                System.out.println(list.get(i) +" "+ map.get(list.get(i)));
            }
        }
    }
}